﻿/*****************************************介绍*****************************************
 * 作者：User
 * 创建时间：2025-09-09 16:14:55
 * 功能：处理游戏界面的线段管理
 *		1、生成
 *		2、销毁
**************************************************************************************/

using Game.Framework;
using UnityEngine;
using UnityEngine.UI;

namespace Game.UI.GamePanel
{
    [RequireComponent(typeof(UILineRenderer))]
    public class LineGenerate : MonoBehaviour, ILineObj
    {
        [SerializeField] GameObject m_Item;

        private void Awake()
        {
            PoolManager.Instance.CreatePool(GamePanelNotifications.LINE_ITEM_POOL, m_Item, 4);
        }

        private void Start()
        {
            GetComponent<UILineRenderer>().Init(this);
        }

        public Image Get()
        {
            var obj = PoolManager.Instance.Get(GamePanelNotifications.LINE_ITEM_POOL);
            return obj.GetComponent<Image>();
        }

        public void Delete(GameObject line)
        {
            PoolManager.Instance.Delete(GamePanelNotifications.LINE_ITEM_POOL, line);
        }

        private void OnDestroy()
        {
            PoolManager.Instance.ClearPool(GamePanelNotifications.LINE_ITEM_POOL);
        }
    }
}